import cv2

img = cv2.imread('/Volumes/D/study/machinelearning/opencv/testpic/lenacolor.bmp')
# cv2.imshow('hello world',img)

# 进行高斯平滑处理
imageGuass = cv2.GaussianBlur(img, (5, 5), 0)

# 改变图片大小
image1 = cv2.resize(img, (int(img.shape[1] / 2), int(img.shape[0] / 2)))
# 再将image1缩小一半
image2 = cv2.pyrDown(image1)
# 灰度chuli
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# 再二值化图片,不关心第一个返回值，用下划线代替
_, gray1 = cv2.threshold(gray, 120, 0xff, cv2.THRESH_BINARY)

# cv2.imshow("Source image.",img)
# cv2.imshow("Resize image.",image1)
# cv2.imshow("quarter image.",image2)
# cv2.imshow("gray image.", gray)
# cv2.imshow("threshold image.", gray1)

# 将通道分离
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
cv2.imshow("hue.", hsv[:, :, 0])
cv2.imshow("Saturation.", hsv[:, :, 1])
cv2.imshow("value.", hsv[:, :, 2])

# 原色bgr显示
cv2.imshow("blue.", img[:, :, 0])
cv2.imshow("green.", img[:, :, 1])
cv2.imshow("red.", img[:, :, 2])

cv2.waitKey()
cv2.destroyAllWindows()
